<template>
  <!-- 购买套餐 -->
  <el-dialog title="选择用户" :visible="value" width="500px" custom-class="dialog-box" @close="onClose" @open="onOpen" :close-on-click-modal="false" :append-to-body="true">
    <el-form>
      <el-form-item label="用户：">
        <patientSearch v-model="patientId"></patientSearch>
        <p style="padding-top:10px;">
          <span class="vertical-middle">查询不到？</span>
          <el-link type="primary" class="vertical-middle" @click="onAddUser">去添加</el-link>
        </p>
      </el-form-item>
    </el-form>
    <span slot="footer">
      <el-button type="primary" @click="onSubmit">确 定</el-button>
    </span>
  </el-dialog>
</template>
<script>
export default {
  props: ["value", "curItem"],
  components: {
    patientSearch: () => import("@/pages/_com/patientSearch.vue")
  },
  data() {
    return {
      patientId: ""
    };
  },
  mounted() {
    const th = this;
  },
  methods: {
    onAddUser() {
      const th = this;
      const url = "/page/patientList";
      const bo = th.verifyUrl(url);
      if (bo) {
        th.onClose();
        th.addNavMenu("病人库", url);
        th.$router.push({
          path: url
        });
      } else {
        th.$message.warning("拒绝访问");
      }
    },
    onSubmit() {
      const th = this;
      if (!th.patientId) {
        th.$message.warning("请选择用户");
        return;
      }
      th.$emit("success",th.patientId)
      th.onClose();
    },
    onOpen() {
      const th = this;
    },
    onClose() {
      const th = this;
      th.$emit("input", false);
    }
  }
};
</script>